﻿' ----------------------------------------------------------------------
'
' FileSystemItemSet.vb
'
'   Dbfs.Entities
'
'   This class contains the set of FileSystemItems that comprise the
'   history of a node in Dbfs.
'
' ----------------------------------------------------------------------
' version:  1.0.0.2
' today:    10/22/09  08:43:00
' ident:    "@(#)/Dbfs/Entities/FileSystemItemSet.vb 1.0 0.1 10/22/09 0 rjs"


Namespace Dbfs

    ''' <summary>
    ''' Implements a collection of <see cref="FileSystemItem"/> the comprise the
    ''' history of a node in Dbfs.
    ''' </summary>
    ''' <remarks>The item set is not updatable and is shared across users.</remarks>
    <SerializableAttribute()> _
    Public Class FileSystemItemSet
        Inherits NodeCollection(Of FileSystemItem)


#Region " Properties "
        ''' <summary>
        ''' Gets the value associated with the specified key. 
        ''' </summary>
        ''' <param name="viewDate">The key of the value to get.</param>
        ''' <value>The value associated with the specified key. If no value can be
        ''' associate with the specified key, a null reference (<b>Nothing</b> in Visual Basic)
        ''' is returned.</value>
        ''' <returns>If no history of the current node is maintained, this property
        ''' always returns the current item.</returns>
        ''' <remarks>This property provides the ability to access a specific element 
        ''' in the collection by using a "fuzzy" key.  The most recent item in the history
        ''' collection with a delete date greater than <paramref name="viewDate"/> is
        ''' returned.</remarks>
        Default Public Overloads ReadOnly Property Item(ByVal viewDate As Date)
            Get
                Dim i As Int16
                For i = 0 To Count - 1
                    If Me(i).DeleteTimeUtc < viewDate Then Exit For
                Next
                If i = 0 Then Return Nothing
                Return Me(i - 1)
            End Get
        End Property
#End Region ' Properties

    End Class

End Namespace


